/*
 * Created on Jun 7, 2005
 *
 */
package com.erclab.internal.xpresso.reports;

import java.util.HashMap;

import com.erclab.internal.xpresso.security.User;

/**
 * @author Enrique Rodriguez.
 *
 */
public class ReportParameters {
	protected HashMap conditions;
	protected HashMap requestParameters;
	protected String uniqueKeyValue;
	protected String parentKeyValue;
	protected boolean exportFlag;
	protected int pageNum;
	protected String sortColumn;
	protected User user;
	protected String requestedView;
	
	
	public String getRequestedView() {
		return requestedView;
	}

	public void setRequestedView(String requestedView) {
		this.requestedView = requestedView;
	}

	/**
	 * @return
	 */
	public HashMap getConditions() {
		return conditions;
	}

	/**
	 * @return
	 */
	public int getPageNum() {
		return pageNum;
	}

	/**
	 * @return
	 */
	public String getParentKeyValue() {
		return parentKeyValue;
	}

	/**
	 * @return
	 */
	public String getUniqueKeyValue() {
		return uniqueKeyValue;
	}

	/**
	 * @return
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param map
	 */
	public void setConditions(HashMap map) {
		conditions = map;
	}
	
	public void setConditions(String conditions){
		// TODO convert String to hashmap
	}

	/**
	 * @param i
	 */
	public void setPageNum(int i) {
		pageNum = i;
	}
	
	public void setPageNum(String i){
		if (i != null && !i.equals("") && !i.equals("null")){
			pageNum = Integer.parseInt(i);
		} else {
			pageNum = 1;
		}
	}

	/**
	 * @param string
	 */
	public void setParentKeyValue(String string) {
		parentKeyValue = string;
	}

	/**
	 * @param string
	 */
	public void setUniqueKeyValue(String string) {
		uniqueKeyValue = string;
	}

	/**
	 * @param user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return
	 */
	public String getSortColumn() {
		return sortColumn;
	}

	/**
	 * @param string
	 */
	public void setSortColumn(String string) {
		sortColumn = string;
	}
	
	/**
	 * Convert the conditions hashmap into an url string
	 */
	public String getUrlConditons(){
		// TODO: Convert the conditions hashmap into an url string
		return null;
	}

	/**
	 * @return
	 */
	public boolean getExportFlag() {
		return exportFlag;
	}

	/**
	 * @param b
	 */
	public void setExportFlag(boolean b) {
		exportFlag = b;
	}
	
	public void setExportFlag(String flag){
		this.exportFlag = (flag != null && flag.equals("Y"));
	}

	/**
	 * @return
	 */
	public HashMap getRequestParameters() {
		return requestParameters;
	}

	/**
	 * @param map
	 */
	public void setRequestParameters(HashMap map) {
		requestParameters = map;
	}

}
